package com.bestcem.xm.ticket.enums;

import lombok.Getter;
import lombok.ToString;

/**
 * 工单配置状态枚举
 *
 * @author liheng
 * @version v1.0
 * @date 2021/8/16 11:05
 */
@Getter
@ToString
public enum TicketConfigStateEnum {
    /**
     *
     */
    ENABLE(0, "ENABLE"),

    /**
     *
     */
    DISABLE(1, "DISABLE"),

    /**
     *
     */
    DELETE(2, "DELETE");

    private final String name;
    private final Integer index;

    TicketConfigStateEnum(Integer index, String name) {
        this.name = name;
        this.index = index;
    }

    /**
     * 根据 index 获取枚举实体
     * 找不到则返回 null
     *
     * @param index 枚举index
     * @author XiaoYunSong <ys.xiao@idiaoyan.com>
     * @date 2021/8/18 14:44
     */
    public static TicketConfigStateEnum getByIndex(Integer index) {
        for (TicketConfigStateEnum value : values()) {
            if (value.getIndex().equals(index)) {
                return value;
            }
        }
        return null;
    }
}
